//
//  UILabel+XM.m
//  SmartContorary
//
//  Created by enghou on 17/6/2.
//  Copyright © 2017年 xyxorigation. All rights reserved.
//

#import "UILabel+CaculateSize.h"
//static CGFloat maxHeight = 1000;
@implementation UILabel (CaculateSize)

//-(void)gapWithHeight:(CGFloat)height{
//    if (self.text==nil) {
//        return;
//    }
//    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
//    paragraphStyle.lineSpacing = height;
//    NSDictionary *attributes = @{NSFontAttributeName:self.font, NSParagraphStyleAttributeName:paragraphStyle};
//    self.attributedText = [[NSAttributedString alloc]initWithString:self.text attributes:attributes];
//}

//-(CGSize)attributedSizeWithMaxWidth:(CGFloat)width{
//    if (self.attributedText==nil) {
//        return [self textSize];
//    }else{
//        return [self.text defaultAttributedSizeWithMaxSize:CGSizeMake(width,10000)];
//    }
//}

-(CGSize)textSize{
    if (nil == self.text) {
        if (self.attributedText) {
            return CGSizeZero;
        }
        return CGSizeZero;
    }
    if (self.font) {
        return [self.text sizeWithFnt:self.font];
    }
    return CGSizeZero;
}

-(CGSize)textSizeWithMaxWidth:(CGFloat)width{
    if (nil == self.text) {
        return CGSizeZero;
    }
    if (self.font) {
        return [self.text caculateSizeWithFont:self.font MaxSize:CGSizeMake(width, 10000)];
    }
    return CGSizeZero;
}


//-(CGSize)textSizeWithMultiLine:(BOOL)multiLine maxWidth:(CGFloat)width{
//    if (nil == self.text || nil == self.font) {
//        return CGSizeZero;
//    }
//    if (multiLine) {
//        return [self.text caculateSizeWithFont:self.font MaxSize:CGSizeMake(width, maxHeight)];
//    }else{
//        return [self.text sizeWithFnt:self.font];
//    }
//}

@end
